<script setup>
import { computed, ref } from 'vue'
const age = ref(18)
const nextAge = computed(() => {
  return +age.value + 1
})

const nextAge2 = computed({
  get () {
    /* 进入就触发 */ 
    return +age.value + 2
  },
  set (value) {
    /* 值被修改就触发 */
    console.log(value, 2222);
    age.value = value - 2
  }
})
</script>
<template>
  <div>我今年的年纪 <input type="text" v-model="age" /></div>
  <div>我明年的年龄 {{ nextAge }}</div>
  <div>我后年的年龄 <input type="text" v-model="nextAge2" /></div>
</template>
<style lang='less'  scoped>
</style>